/*
 * Copyright (C) 2021 Huawei Device Co., Ltd.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain an copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package cn.nekocode.badge.slice;
import cn.nekocode.badge.BadgeDrawable;
import cn.nekocode.badge.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.Image;
import ohos.agp.components.Text;
import ohos.agp.utils.Color;

/**
 * 主页面
 *
 * @since 2021-04-23
 */
public class MainAbilitySlice extends AbilitySlice {
    private static final int COLOR1 = 0xffcc3232;
    private static final int COLOR2 = 0xff326699;
    private static final int COLOR3 = 0xffcc9932;
    private static final int COLOR4 = 0xffcd9b9b;
    private static final int COLOR5 = 0xff326632;
    private String typeFace = "code-bold.otf";
    private final int number = 9;
    private final int number2 = 666666;
    private final int textSize = 15;

    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        super.setUIContent(ResourceTable.Layout_ability_main);
        initView();
    }

    private void initView() {
        Text textView = (Text) findComponentById(ResourceTable.Id_tvHelloWorld);
        Text text2 = (Text) findComponentById(ResourceTable.Id_tv2);
        Text text3 = (Text) findComponentById(ResourceTable.Id_tv3);
        Text text4 = (Text) findComponentById(ResourceTable.Id_tv4);
        Text text5 = (Text) findComponentById(ResourceTable.Id_tv5);
        Image imageView = (Image) findComponentById(ResourceTable.Id_imageView);

        BadgeDrawable.Builder(this, textView)
                .setBadgeColor(new Color(COLOR1))
                .setBadgeType(BadgeDrawable.TYPE_NUMBER)
                .setNumber(number)
                .setTextColor(Color.WHITE)
                .setTextSize(18,Text.TextSizeType.FP)
                .build();

        BadgeDrawable.Builder(this, text2)
                .setBadgeColor(new Color(COLOR2))
                .setBadgeType(BadgeDrawable.TYPE_ONLY_ONE_TEXT)
                .setText1("VIP")
                .build();
        BadgeDrawable.Builder(this, text3)
                .setBadgeColor(new Color(COLOR3))
                .setBadgeType(BadgeDrawable.TYPE_WITH_TWO_TEXT)
                .setText1("LEVEL")
                .setText2("10")
                .build();
        BadgeDrawable.Builder(this, text4)
                .setBadgeColor(new Color(COLOR4))
                .setBadgeType(BadgeDrawable.TYPE_WITH_TWO_TEXT_COMPLEMENTARY)
                .setText1("TEST")
                .setText2("Pass")
                .build();
        BadgeDrawable.Builder(this, text5)
                .setBadgeColor(new Color(COLOR2))
                .setBadgeType(BadgeDrawable.TYPE_NUMBER)
                .setNumber(number2)
                .setTextColor(Color.WHITE)
                .build();
        BadgeDrawable.Builder(this, imageView)
                .setBadgeColor(new Color(COLOR5))
                .setTextSize(textSize, Text.TextSizeType.FP)
                .setBadgeType(BadgeDrawable.TYPE_WITH_TWO_IMAGE)
                .setText1("AUTHOR")
                .setText2("NEKOCODE")
                .build();
    }

    @Override
    public void onActive() {
        super.onActive();
    }

    @Override
    public void onForeground(Intent intent) {
        super.onForeground(intent);
    }
}
